package com.tsubaki.controller;


import com.alibaba.fastjson.JSON;
import com.tsubaki.entity.UserRole;
import com.tsubaki.mapper.UserRoleMapper;
import com.tsubaki.response.Result;
import com.tsubaki.service.UserRoleService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tsubaki
 * @since 2022-01-17
 */
@RestController
@RequestMapping("/user-role")
public class UserRoleController {

    @Autowired
    private UserRoleService userRoleService;

    @ApiOperation("为角色赋予权限")
//    @RequiresPermissions("user:role")
    @RequestMapping(value = "/permission", method = RequestMethod.POST)
    public String addPermission(@RequestBody UserRole userRole) {

        System.out.println(userRole.getRoleId()+"***"+userRole.getUserId());
        userRoleService.addPermission(userRole);

        return JSON.toJSONString(new Result().setCode(200).setMessage("添加成功"));
    }
}
